
#include "xdns-name-query.h"
#include "xdns-data.h"
#include "xdns-encoder.h"
#include "xdns-protocol.h"
#include "xdns-question-info.h"

using namespace std;

XdnsNameQuery::XdnsNameQuery(const string& hostname,
                             XdnsListener* listener)
: XdnsQuery(XQT_Hostname, listener),
  m_hostname(hostname)
{
}

XdnsNameQuery::~XdnsNameQuery()
{
}

string
XdnsNameQuery::GetHostname() const
{
    return m_hostname;
}

XdnsError
XdnsNameQuery::ComposeQueryData(unsigned short requestId,
                                XdnsData& data
                                ) const
{
    return XdnsEncoder::GenerateData(requestId,
                                     XDNS_TYPE_A,
                                     XDNS_CLASS_IN,
                                     m_hostname,
                                     data);
}

void
XdnsNameQuery::GetQuestion(XdnsQuestionInfo& question) const
{
    question.m_qtype = XDNS_TYPE_A;
    question.m_qclass = XDNS_CLASS_IN;
    question.m_qname = m_hostname;
}

